[13.x] Check traits in resolveClassAttribute - #60566
Merged
taylorotwell merged 4 commits intoJul 22, 2026
Merged
Conversation
Matches queues etc.
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
jackbayliss
marked this pull request as ready for review
July 21, 2026 20:29
irabbi360
added a commit
to irabbi360/framework
that referenced
this pull request
Jul 31, 2026
Fixes laravel#60953 After laravel#60566 / laravel#60519, class attributes like `#[Table]` and `#[Connection]` can live on traits. That works fine, but if two traits on the same class declare the same attribute with different values, we just picked the first trait in the `use` list and moved on. That means something as harmless as reordering imports / traits can change runtime behaviour, which feels a bit nasty. This PR makes that conflict explicit instead: - if multiple traits declare the same attribute with **different** values → throw a `LogicException` - if they declare the **same** value → still fine - class-level attributes still win over traits (unchanged) Shared the trait lookup in `Reflector::getClassAttributeFromTraits()` and wired it into both `Model::resolveClassAttribute()` and `ReadsClassAttributes` so Eloquent and queue attributes stay consistent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the exact same as I did here #60519
This means queue attributes 🤝 model attributes (We are same same but different)
This essentially means, traits can carry model attributes which means we can put attributes on a trait, and reuse the trait.
This only checks traits on the current class in the hierarchy same as the other PR
Nice for package maintainers, or teams using traits.
I'm completely fine if you close this, just thought I'd try bring the same behaviour as queues to models for the attributes 🫡